﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessPlatform.Core.BusinessObject;


namespace BusinessPlatform.Core.Result
{
    /// <summary>
    /// 返回结果
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Result<T> : IResultT<T>
    {
        #region private variable
        private IList<T> _BusinessObject;
        private bool _ResultFlag;
        private string _ResultMessage;
        #endregion

        public Result()
        {
            _BusinessObject = new List<T>();
            _ResultFlag = false;
        }
        /// <summary>
        /// 返回T类型的结果集
        /// </summary>
        public IList<T> BusinessObject
        {
            get
            {
                return _BusinessObject;
            }
        }
        /// <summary>
        /// 返回结果集
        /// </summary>
        IList IResult.BusinessObject
        {
            get { return this.BusinessObject.ToList<T>(); }
        }
        /// <summary>
        /// 返回操作结果标志
        /// </summary>
        public bool ResultFlag
        {
            get
            {
                return _ResultFlag;
            }
        }
        /// <summary>
        /// 返回操作结果信息
        /// </summary>
        public string ResultMessage
        {
            get
            {
                return _ResultMessage;
            }
        }
        /// <summary>
        /// 设置操作标志
        /// </summary>
        /// <param name="Flag"></param>
        void IResultT<T>.SetResultFlag(bool Flag)
        {
            _ResultFlag = Flag;
        }
        /// <summary>
        /// 设置操作结果
        /// </summary>
        /// <param name="Flag"></param>
        /// <param name="Message"></param>
        void IResultT<T>.SetResult(bool Flag, string Message)
        {
            _ResultFlag = Flag;
            _ResultMessage = Message;
        }
    }
}
